package com.bclz.datastructures

object TestDataStructures {


  def main(args: Array[String]): Unit = {
    val testList = List(1, 2, 3, 4, 5)
    val testDoubleList=List(1.0,2.0,3.0,4.0,5.0)
    println(List.apply("1",2,"3",444,true))

    println(testList match {
      case Cons(x, Cons(2, Cons(4, _))) => x
      case Nil => 42
      case Cons(x, Cons(y, Cons(3, Cons(4, _)))) => x + y
      case Cons(h, t) => h + List.sum(t)
      case _ => 101
    })

    println(List.drop(testList,2))

    //需要声明a的参数类型
    println(List.dropWhile(testList,(a:Int)=>a==1||a==4))
    //高阶函数的类型推导，从左到右
    println(List.dropWhileNew(testList)(a=>a==1||a==4))

    println(List.sumV2(testList))
    println(List.productV2(testDoubleList))
    println(List.length(testList))

    println(List.reverse(testList))

    println(List.append(testList,Cons(99,Nil)))

    val listList=List(List(1,2,3),List('q','w','e'))
    println(List.concat(listList))
  }

}
